{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">预约管理</div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"
                data-auth-add="{:$auth->check('auth.manager/add')}" 
                data-auth-edit="{:$auth->check('auth.manager/edit')}"
                data-auth-delete="{:$auth->check('auth.manager/del')}"></table>
        </div>
    </div>

    <script type="text/html" id="barTool">
        <a href='{:url("edit")}?id={{ d.id }}' class="layui-btn layui-btn-xs {:$auth->check('staff.index/edit')?'':'layui-hide'}" title="查看详情">查看详情</a>
        <a href='{:url("del")}?id={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del {:$auth->check('staff.index/del')?'':'layui-hide'}"><i class='iconfont icon-trash_fill'></i></a>
    </script>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
layui.use('yznTable', function() {
    var table = layui.yznTable;

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTable',
        add_url: '{:url("add")}',
        edit_url: '{:url("edit")}',
        delete_url: '{:url("del")}',
        modify_url:'{:url("multi")}',

    };


    var mydata = [];
    $.ajax({
        url: 'admin/index/getArea',
        async: false,
        dataType: 'json',
        success: function (result) {
            mydata = result;
        }
    });

    console.log(mydata);

    table.render({
        init: init,
        toolbar: ['refresh'],
        url: '{:url("index")}',
        cols: yznTable.formatCols([
            [
                { field: 'id', width: 80, title: 'ID',search:false},
                { field: 'staff.name', align:'center',  title: '用户昵称', searchOp: 'like' },
                { field: 'staff.phone', align:'center',  title: '手机号', searchOp: 'like' },
                { field: 'makeTime', align:'center',  title: '预约时间',search: 'range',searchOp: 'like'},
                { field: 'area.id', align:'center',  title: '区域名称',templet: yznTable.formatter.label,selectList: mydata},
                { field: 'car.number', align:'center',  title: '车辆编号'},
                { field: 'makeCarTime', align:'center', title: '用车时长', search:false},

                { field: 'timeOut', align:'center', title: '超时', search:false},
                { field: 'status.status', align:'center',fieldAlias:'order.status',   title: '状态',templet: yznTable.formatter.label,selectList: {0:'已预约',1:'使用中',2:'已归还',3:'已取消',4:'超时自动取消'}},

                { field: 'createTime',align:'center',search: 'range',  title: '创建时间', searchOp: 'like'  },
                { fixed: 'right', align: 'center', width: 140, title: '操作', toolbar: '#barTool' }
            ]
        ],init),
        page: {}
    });
    yznTable.listenSwitch({filter: 'status', url: init.modify_url});

    yznTable.bindevent();
});
</script>
{/block}